import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'

import '@/plugins/svgIcon'
import '@/plugins/unocss'
import '@/assets/theme/index.less'
import '@/plugins/animate.css'
import 'element-plus/dist/index.css'

import { setupI18n } from '@/plugins/vueI18n'
import { setupStore } from '@/store'
import { setupRouter } from './router'
import { setupGlobCom } from '@/components'
import { setupPermission } from './directives'

import './permission'

import VueViewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'


async function setupAll() {
  const app = createApp(App)

  await setupI18n(app) // 等待 i18n 初始化

  setupGlobCom(app)
  setupRouter(app)
  setupStore(app)
  setupPermission(app)

  app.use(ElementPlus)

  app.config.errorHandler = (err, vm, info) => {
    console.error('Vue errorHandler:', err, info)
  }

  app.use(VueViewer);

  app.mount('#app')
}

setupAll()
